import {defineStore} from 'pinia';

const app_url = import.meta.env.VITE_APP_URL;

const login_url = app_url + '/#/login';

interface UserInfo {
    id?: string;
    token?: string;
    loginurl?: string;
    userId?: number;
    username?: string;
    cityName?: string;
    userMenuDataList?: [],
    accessUrlData?: []
}

export const useUserStore = defineStore('user', {
    state: () => {
        return {
            userInfo: <UserInfo>{loginurl: login_url}
        };
    },
    getters: {
        user: state => {
            return state.userInfo;
        }
    },
    actions: {
        setUserInfo(user: UserInfo) {
            this.userInfo = user;
        }
    },
    persist: true,
});
